﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Pager;
using X.Pager.List;
using X.Common;

namespace E.Web.Teacher.internals.classes
{
    public partial class List : TeacherBasePage
    {
        public Dictionary<int, string> courseList = new Dictionary<int, string>();
        public Dictionary<int, string> projectList = new Dictionary<int, string>();
        public string act, classCode;
        public int courseid, projectid;
        public IList<InternalClassModel> classList;
        public int delflag = -1;

        protected override void ShowPage()
        {
            CourseBLL courseBLL = new CourseBLL();
            if (authority != E.Enum.EnumTeacherAuthority.Admin)
            {
                courseList = courseBLL.GetCourseListByTeacherID(teacherid);
                projectList = courseBLL.GetTeacherProjectList(teacherid);
            }
            else
            {
                courseList = courseBLL.GetInternalCourseList();
                projectList = courseBLL.GetInternalProjectList();
            }

            act = XRequest.GetString("act");
            classCode = XRequest.GetString("ClassCodeTxt");
            courseid = XRequest.GetInt("CourseSlt", -1);
            projectid = XRequest.GetInt("ProjectSlt", -1);


            if (ispost || act == "s")
            {
                ClassBLL bll = new ClassBLL();

                InternalClassSearchModel searchModel = new InternalClassSearchModel();
                searchModel.ClassCode = classCode;
                searchModel.CourseID = courseid;
                searchModel.ProjectID = projectid;
                searchModel.DelFlag = delflag;
                searchModel.SkillGroup = -1;

                InternalClassListModel listModel = new InternalClassListModel();

                CheckPageIndexValue(XRequest.GetInt("s", 1) - 1, XRequest.GetInt("g", 0), XRequest.GetInt("z", customerPageSize));

                listModel = bll.GetInternalClassListByCondition(searchModel, customerPageSize, pageIndex);
                if (listModel.TotalCount > 0)
                {
                    count = listModel.TotalCount;
                    classList = listModel.List;
                    PagerBase pager = new ListPager(count, pageIndex, currentPgGroup, customerPageSize, defaultPagesInGroup);

                    Dictionary<string, string> parms = new Dictionary<string, string>();
                    parms.Add("act", act);
                    parms.Add("ClassCodeTxt", classCode);
                    parms.Add("CourseSlt", courseid.ToString());
                    parms.Add("ProjectSlt", projectid.ToString());
                    parms.Add("AreaSlt", areaid.ToString());
                    parms.Add("DelFlagSlt", delflag.ToString());
                    mypager = pager.DrawPager("selfpager", parms);
                }
                //}
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}
